#ifndef __YQLQUOTES_HPP__
#define __YQLQUOTES_HPP__

#include <string>
#include <vector>

#include "FieldNameLookup.hpp"
#include "ResultQuote.hpp"


// Forward declaration
namespace tinyxml2 {
   class XMLElement;  
}


class YQLQuotes
{
public: // TOR's
  YQLQuotes();
public: // Public setup
   void addSymbol(std::string symbol);
   void clearSymbols();
public: // Public Execute
   bool loadFromYQL();    // TODO some mechanism to keep track of where/what we loaded from, and which parse to call
   bool loadFromSQL();    
   bool loadFromFile();
   bool loadFromString(std::string str);
   bool saveToSQL();
   bool saveToFile();
   bool parseXML();
public: // Accessors
   std::string   getURL()      { return this->strURL; }
   std::string   getXML()      { return this->strXML; }
   bool  getLoadSuccess()      { return this->loadSuccess; }
   unsigned int getNumQuotes() { return this->vecQuotes.size(); }
   bool getQuote(int index, ResultQuote& quote);
  
private: // Private Utility
   std::string buildURL();
   bool processXMLQuote(tinyxml2::XMLElement* quote);
   FieldNameLookup fieldNameLookup;       // For internal lookups, expensive xtor, define here and reuse
private: // Private vars
   std::vector<std::string> symbolList;   // List of all symbols to get data for
   bool loadSuccess;                      // True when strXML contains valid data. Defaults to false.
   std::string strURL;                    // Result of buildURL(), where our data comes from when fetching from http:// resources
   std::string strXML;                    // Raw XML loaded from any source, http://, local file, sql
   int numQuoteErrors;                    // How many <QUOTE> items did ResultQuote fail to parse
   std::vector<ResultQuote> vecQuotes;    // Holds each decoded ResultQuote from the XML
};


#endif
